package com.blb.zycommunity.controller;

import com.blb.zycommunity.entity.ResponseResult;
import com.blb.zycommunity.entity.ZyLiked;
import com.blb.zycommunity.service.IZyLikedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author chenheng
 * @since 2023-11-20
 */
@RestController
public class ZyLikedController {

    @Autowired
    private IZyLikedService zyLikedService;

    @PostMapping("/liked")
    public ResponseResult saveLiked(@RequestParam String interactionId,
                                    @RequestParam String ownerId){
        zyLikedService.saveLiked(interactionId,ownerId);
        return ResponseResult.ok("ok");
    }

    @GetMapping("/liked-list")
    public ResponseResult<List<ZyLiked>> likedList(){
        List<ZyLiked> likedList = zyLikedService.list();
        return ResponseResult.ok(likedList);
    }

    @DeleteMapping("/liked")
    public ResponseResult liked(String interactionId,String ownerId){
        zyLikedService.removeLiked(interactionId,ownerId);
        return ResponseResult.ok("ok");
    }


}
